#ifndef HTTPREQUEST_H
#define HTTPREQUEST_H

#include <QObject>

class QNetworkAccessManager;
class QNetworkRequest;

class HttpRequest : public QObject
{
    Q_OBJECT
public:
    static QString m_requestHeader;
    static QVariantMap m_map_post;
    static QVariantMap m_map_get;


public:
    explicit HttpRequest(QObject *parent,const QString requestHeader);

    ~HttpRequest();

    static QString requestHeader();
    static void setRequestHeader(const QString &requestHeader);

    static QVariantMap getMap_post();
    static void setMap_post(const QVariantMap &map_post);

    static QVariantMap getMap_get();
    static void setMap_get(const QVariantMap &map_get);

    static bool isValidIpPortFormat(const QString &ipPortString);

public:

    int NormalGetRequest(const QString &path, const QMap<QString, QString> &keyValuePairs);

    int NormalPostRequest(const QString &path, const QMap<QString, QString> &keyValuePairs);

    bool isUrlValid(const QString &url);

    bool isValidIPv4(const QString &ipAddress);
    QJsonObject parseJson(const QString &jsonString);
public slots:
    bool PostCsvUploadInfo(const QString &path, const QString &filePath);
    void sendCsvJson(HttpRequest *m_http, QString Path, QString fileName);
    bool GetCsvUploadInfo(const QString &path, const QString &filePath);
signals:
    void updateIpPort();

private slots:

    void do_RequestFinished();

private:
    QString m_url;
};

#endif // HTTPREQUEST_H
